package itbour.onetouchshow.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import itbour.onetouchshow.R;


/**
 * Created by guoh on 2018/7/5.
 * 功能描述：
 * 需要的参数：
 */
public class VerticalVideoRecordProgress extends LinearLayout {
    private LinearLayout totalCount;
    private View progress;
    private RotateTextView tvSecond;

    public VerticalVideoRecordProgress(Context context) {
        super(context);
        initView(context);
    }

    public VerticalVideoRecordProgress(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }


    private void initView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.view_vertical_video_record_progress, this);
        totalCount = view.findViewById(R.id.ll_total_count);
        progress = view.findViewById(R.id.v_progress);
        tvSecond = view.findViewById(R.id.tv_second);
    }

    public void setTotalCount(int total) {
        totalCount.setWeightSum(total);
    }

    public void setProgress(int pro) {
        LinearLayout.LayoutParams params = (LayoutParams) progress.getLayoutParams();
        params.weight = pro;
        progress.setLayoutParams(params);
        tvSecond.setText(pro + "s");
    }

    public void resetProgress() {
        LinearLayout.LayoutParams params = (LayoutParams) progress.getLayoutParams();
        params.weight = 0;
        progress.setLayoutParams(params);
        tvSecond.setText(0 + "s");
    }
}
